package com.zhht.checkcop;

import java.util.List;
import java.util.Map;

import com.zhht.checkcop.db.MysqlDb;
import com.zhht.checkcop.demo.MovieInfoInitialization;
import com.zhht.checkcop.demo.MovieUpdate;

public class MyMain {
	
//	public static void main(String[] args) {
//		if(args==null||args.length==0){
//			System.out.println("参数不正确。参数1：线程数       参数2.更新电影目录传 1   更新电影详情传2");
//			return ;
//		}
//		//88网
//		if("1".equals(args[1])){
//			if("1".equals(args[2])){
//				MovieUpdate.main(args);
//			}else if("2".equals(args[2])){
//				MovieInfoInitialization.main(args);
//			}else if("3".equals(args[2])){
//				
//			}
//		}
//	}
	
	public static void main(String[] args) throws Exception{
    	MysqlDb mysqldb = new MysqlDb();
    	mysqldb.connect();
    	List<Map<String, Object>> list = mysqldb.query("select id,`name` from t_gf_authors where sync = 0 LIMIT 10000,5000");
    	for(Map<String,Object> mm:list){
    		System.out.println("更新：bookId :"+mm.get("id")+"   name:"+(mm.get("name")+"").trim());
    		String name = mm.get("name")+"";
    		String id = mm.get("id")+"";
    		List<Map<String, Object>> list2 = mysqldb.query("select kind_one,count(1) num from t_gf_book where author = '"+name+"' GROUP BY kind_one");
    		int num=0;
    		int num1=0;
    		int num2=0;
    		int num3=0;
    		int num4=0;
    		int num5=0;
    		int num6=0;
    		if(list2!=null&&list2.size()>0){
    			for(Map<String,Object> xx:list2){
    				int kind = Integer.parseInt(xx.get("kind_one")+"");
    				int nums = Integer.parseInt(xx.get("num")+"");
    				num+=nums;
					switch (kind) {
					case 1:
						num1=nums;
						break;
					case 2:
						num2=nums;
						break;
					case 3:
						num3=nums;
						break;
					case 4:
						num4=nums;
						break;
					case 5:
						num5=nums;
						break;
					case 6:
						num6=nums;
						break;
					default:
						break;
					}
    			}
    			
    			mysqldb.execute("update t_gf_authors set sync = 1,works_shi_count="+num1+",works_ci_count="+num2+",works_qu_count="+num3+",works_fu_count="+num4+",works_shu_count="+num5+",works_wen_count="+num6+",works_count="+num+" where id = "+id);
    		}
    	}
	}
}
